﻿using LiteBlog.Repositories.Common;
using LiteBlog.XmlLayer.Mocks.Constants;
using Moq;
using System.Xml.Linq;

namespace LiteBlog.Repositories.Mocks
{
    public class TagDataMock
    {
        public static IXmlHelper GetMock()
        {
            var mocked = Mock.Of<IXmlHelper>();
            var mock = Mock.Get<IXmlHelper>(mocked);
            var root = new XElement(Elem.Tags,
                          new XElement(Elem.Tag,
                              new XAttribute(Attr.Id3, TagDataTestConstants.Id),
                              new XAttribute(Attr.Name, TagDataTestConstants.Name),
                              new XAttribute(Attr.Count, CountDataTestConstants.Count)),
                          new XElement(Elem.Tag,
                              new XAttribute(Attr.Id3, TagDataTestConstants.UpdateId),
                              new XAttribute(Attr.Name, TagDataTestConstants.Name),
                              new XAttribute(Attr.Count, TagDataTestConstants.OldCount)),
                          new XElement(Elem.Tag,
                              new XAttribute(Attr.Id3, TagDataTestConstants.DeleteId),
                              new XAttribute(Attr.Name, TagDataTestConstants.Name),
                              new XAttribute(Attr.Count, CountDataTestConstants.Count)));

            mock.Setup(x => x.Load(It.IsAny<string>()))
                 .Returns(root);
            return mocked;
        }
    }
}
